<template>
  <div class="topnav">
    <div class="logo">
      <router-link to="/">
        <svg class="icon">
          <use xlink:href="#icon-chengzi2"></use>
        </svg>
      </router-link>
    </div>
    <ul class="menu">
      <li><router-link to="/doc/intro">文档</router-link ></li>
      <li><router-link to="/doc/switch">组件列表</router-link ></li>
    </ul>
    <span class="toogleAside" @click="toogleMenu">
      <i></i>
      <i></i>
      <i></i>
    </span>
  </div>
</template>

<script lang="ts">
import { inject, Ref } from "vue";
export default {
  components: {},
  setup() {
    const menuVisible = inject<Ref<boolean>>("menuVisible"); //get
    // console.log(menuVisible)
    const toogleMenu = () => {
      menuVisible.value = !menuVisible.value;
      console.log(menuVisible.value);
    };
    return {
      toogleMenu,
    };
  },
};
</script>
<style lang='scss' scoped>
.topnav {
  box-shadow: rgb(252 80 0 / 45%) 0px 5px 5px;
  background: white;
  display: flex;
  padding: 16px;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  justify-content: center;
  align-items: center;
  > .logo {
    max-width: 6em;
    margin-right: auto;
    > a {
      text-decoration: none;
      > .icon {
        width: 50px;
        height: 60px;
      }
    }
  }
  > .menu {
    display: flex;
    white-space: nowrap;
    flex-wrap: nowrap;
    > li {
      margin: 0 1em;
       > a:hover {
        color: rgb(64, 169, 255);
        text-decoration: none;
        border-bottom: none;
      }
    }
  }
  > .toogleAside {
    display: none;
    width: 24px;
    height: auto;
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    > i {
      width: 100%;
      margin-top: 6px;
      height: 3px;
      /* margin-bottom: .5rem; */
      background: black;
      display: block;
    }
  }
  @media (max-width: 500px) {
    > .menu {
      display: none;
    }
    > .logo {
      margin: 0 auto;
    }
    > .toogleAside {
      display: inline-block;
    }
  }
}
</style>